﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdDbDimAssoc : OdDbObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDbDimAssoc(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdDbDimAssoc_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDbDimAssoc obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDbDimAssoc()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdDbDimAssoc(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdDbDimAssoc cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbDimAssoc_cast(OdRxObject.getCPtr(pObj));
			OdDbDimAssoc result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbDimAssoc)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbDimAssoc)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbDimAssoc)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbDimAssoc_desc(), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbDimAssoc_isA(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbDimAssoc_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdDbDimAssoc createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbDimAssoc_createObject();
			OdDbDimAssoc result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbDimAssoc)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbDimAssoc)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbDimAssoc)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdResult dwgInFields(OdDbDwgFiler pFiler)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbDimAssoc_dwgInFields(this.swigCPtr, OdDbDwgFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void dwgOutFields(OdDbDwgFiler pFiler)
		{
			TD_DbPINVOKE.OdDbDimAssoc_dwgOutFields(this.swigCPtr, OdDbDwgFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual OdResult dxfInFields(OdDbDxfFiler pFiler)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbDimAssoc_dxfInFields(this.swigCPtr, OdDbDxfFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void dxfOutFields(OdDbDxfFiler pFiler)
		{
			TD_DbPINVOKE.OdDbDimAssoc_dxfOutFields(this.swigCPtr, OdDbDxfFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbObjectId dimObjId()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr cPtr = TD_DbPINVOKE.OdDbDimAssoc_dimObjId(this.swigCPtr);
			OdDbObjectId result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject(new OdDbObjectId(cPtr, true));
				result = new OdDbObjectId(cPtr, false);
			}
			else
			{
				result = new OdDbObjectId(cPtr, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setDimObjId(OdDbObjectId dimId)
		{
			TD_DbPINVOKE.OdDbDimAssoc_setDimObjId(this.swigCPtr, OdDbObjectId.getCPtr(dimId));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public int assocFlag()
		{
			int result = TD_DbPINVOKE.OdDbDimAssoc_assocFlag__SWIG_0(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool assocFlag(int pointIndex)
		{
			bool result = TD_DbPINVOKE.OdDbDimAssoc_assocFlag__SWIG_1(this.swigCPtr, pointIndex);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setAssocFlag(int assocFlag)
		{
			TD_DbPINVOKE.OdDbDimAssoc_setAssocFlag__SWIG_0(this.swigCPtr, assocFlag);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setAssocFlag(int pointIndex, bool flagValue)
		{
			TD_DbPINVOKE.OdDbDimAssoc_setAssocFlag__SWIG_1(this.swigCPtr, pointIndex, flagValue);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbOsnapPointRef pointRef(int pointIndex)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbDimAssoc_pointRef(this.swigCPtr, pointIndex);
			OdDbOsnapPointRef result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbOsnapPointRef)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbOsnapPointRef)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbOsnapPointRef)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setPointRef(int pointIndex, OdDbOsnapPointRef pOsnapPointRef)
		{
			TD_DbPINVOKE.OdDbDimAssoc_setPointRef(this.swigCPtr, pointIndex, OdDbOsnapPointRef.getCPtr(pOsnapPointRef));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbDimAssoc.RotatedDimType rotatedDimType()
		{
			OdDbDimAssoc.RotatedDimType result = (OdDbDimAssoc.RotatedDimType)TD_DbPINVOKE.OdDbDimAssoc_rotatedDimType(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setRotatedDimType(OdDbDimAssoc.RotatedDimType dimType)
		{
			TD_DbPINVOKE.OdDbDimAssoc_setRotatedDimType(this.swigCPtr, (int)dimType);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void addToPointRefReactor()
		{
			TD_DbPINVOKE.OdDbDimAssoc_addToPointRefReactor(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void addToDimensionReactor(bool isAdd)
		{
			TD_DbPINVOKE.OdDbDimAssoc_addToDimensionReactor__SWIG_0(this.swigCPtr, isAdd);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void addToDimensionReactor()
		{
			TD_DbPINVOKE.OdDbDimAssoc_addToDimensionReactor__SWIG_1(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdResult removePointRef(int ptType)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbDimAssoc_removePointRef(this.swigCPtr, ptType);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdResult updateDimension(bool update, bool skipReactors)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbDimAssoc_updateDimension__SWIG_0(this.swigCPtr, update, skipReactors);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdResult updateDimension(bool update)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbDimAssoc_updateDimension__SWIG_1(this.swigCPtr, update);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdResult updateDimension()
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbDimAssoc_updateDimension__SWIG_2(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void removeAssociativity(bool force)
		{
			TD_DbPINVOKE.OdDbDimAssoc_removeAssociativity__SWIG_0(this.swigCPtr, force);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void removeAssociativity()
		{
			TD_DbPINVOKE.OdDbDimAssoc_removeAssociativity__SWIG_1(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isTransSpatial()
		{
			bool result = TD_DbPINVOKE.OdDbDimAssoc_isTransSpatial(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setTransSpatial(bool value)
		{
			TD_DbPINVOKE.OdDbDimAssoc_setTransSpatial(this.swigCPtr, value);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdResult post(OdDbObjectId dimId, OdDbObjectId dimAssocId, bool isActive)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbDimAssoc_post__SWIG_0(this.swigCPtr, OdDbObjectId.getCPtr(dimId), OdDbObjectId.getCPtr(dimAssocId), isActive);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdResult post(OdDbObjectId dimId, OdDbObjectId dimAssocId)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbDimAssoc_post__SWIG_1(this.swigCPtr, OdDbObjectId.getCPtr(dimId), OdDbObjectId.getCPtr(dimAssocId));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdResult getDimAssocGeomIds(OdDbObjectIdArray geomIds)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbDimAssoc_getDimAssocGeomIds(this.swigCPtr, OdDbObjectIdArray.getCPtr(geomIds));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isAllGeomErased()
		{
			bool result = TD_DbPINVOKE.OdDbDimAssoc_isAllGeomErased(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void modifiedGraphics(OdDbObject pObj)
		{
			TD_DbPINVOKE.OdDbDimAssoc_modifiedGraphics(this.swigCPtr, OdDbObject.getCPtr(pObj));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void copied(OdDbObject pObj, OdDbObject pNewObj)
		{
			TD_DbPINVOKE.OdDbDimAssoc_copied(this.swigCPtr, OdDbObject.getCPtr(pObj), OdDbObject.getCPtr(pNewObj));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void erased(OdDbObject pObj, bool erasing)
		{
			TD_DbPINVOKE.OdDbDimAssoc_erased__SWIG_0(this.swigCPtr, OdDbObject.getCPtr(pObj), erasing);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void erased(OdDbObject pObj)
		{
			TD_DbPINVOKE.OdDbDimAssoc_erased__SWIG_1(this.swigCPtr, OdDbObject.getCPtr(pObj));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void openedForModify(OdDbObject pObject)
		{
			TD_DbPINVOKE.OdDbDimAssoc_openedForModify(this.swigCPtr, OdDbObject.getCPtr(pObject));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual OdDbObject subWblockClone(OdDbIdMapping idMap, OdDbObject pOwner)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbDimAssoc_subWblockClone(this.swigCPtr, OdDbIdMapping.getCPtr(idMap), OdDbObject.getCPtr(pOwner));
			OdDbObject result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbObject)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbObject)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbObject)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdDbObject subDeepClone(OdDbIdMapping idMap, OdDbObject pOwner)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbDimAssoc_subDeepClone(this.swigCPtr, OdDbIdMapping.getCPtr(idMap), OdDbObject.getCPtr(pOwner));
			OdDbObject result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbObject)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbObject)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbObject)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public const int kMaxPointRefs = 4;

		private object locker = new object();

		private HandleRef swigCPtr;

		public enum PointType
		{
			kXline1Point,
			kXline2Point,
			kOriginPoint = 0,
			kDefiningPoint,
			kXline1Start = 0,
			kXline1End,
			kXline2Start,
			kXline2End,
			kVertexPoint = 2,
			kChordPoint = 0,
			kCenterPoint,
			kFarChordPoint = 1,
			kOverrideCenterPoint,
			kAngLineStart = 2,
			kJogPoint,
			kAngLineEnd = 3,
			kLeaderPoint = 0
		}

		public enum RotatedDimType
		{
			kUnknown,
			kParallel,
			kPerpendicular
		}

		[Flags]
		public enum AssocFlags
		{
			kFirstPointRef = 1,
			kSecondPointRef = 2,
			kThirdPointRef = 4,
			kFourthPointRef = 8
		}
	}
}
